package com.chart.chart.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.chart.chart.domian.ChartLabels;
import com.chart.chart.domian.ChartSettings;
import com.chart.chart.domian.ChartStatistics;
import com.chart.chart.mapper.ChartAxisConfigurationMapper;
import com.chart.chart.mapper.ChartLabelsMapper;
import com.chart.chart.mapper.ChartSettingsMapper;
import com.chart.chart.service.IChartSettingsService;
import com.chart.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 此处写该类描述
 *
 * @author 罗继全
 * 2024/7/26 14:35
 */
@Service
public class ChartSettingsServiceImpl extends ServiceImpl<ChartSettingsMapper, ChartSettings> implements IChartSettingsService {

    @Autowired
   private ChartSettingsMapper chartSettingsMapper;
    @Autowired
    private   ChartLabelsMapper chartLabelsMapper;
    @Autowired
    private ChartAxisConfigurationMapper chartAxisConfigurationMapper;
    @Override
    public List<ChartSettings> getAllChartSettings() {
        List<ChartSettings> chartSettingsList = chartSettingsMapper.selectList(null);
        // 遍历结果列表，手动清除不需要的字段

        for (ChartSettings chartSettings : chartSettingsList) {
            // 查询 ChartLabels
            QueryWrapper<ChartLabels> labelsQuery = new QueryWrapper<>();
            labelsQuery.eq("chart_settings_id", chartSettings.getId());

            List<ChartLabels> chartLabels = chartLabelsMapper.selectList(labelsQuery);
            chartSettings.setChildren(chartLabels);

            // 查询 ChartAxisConfiguration
/*            for (ChartLabels label : chartLabels) {
                QueryWrapper<ChartAxisConfiguration> axisQuery = new QueryWrapper<>();
                axisQuery.eq("chart_labels_id", label.getId());
                List<ChartAxisConfiguration> axisConfigurations = chartAxisConfigurationMapper.selectList(axisQuery);
               // label.setChildren(axisConfigurations);

            }*/
        }
        return chartSettingsList;
    }





}


























